package afcp.alumni.service;

import java.util.List;
import java.util.Locale;

import net.sourceforge.stripes.action.Message;
import afcp.alumni.action.base.MyActionBeanContext;
import afcp.alumni.model.SearchResult;
import afcp.alumni.model.db.FileColumn;
import afcp.alumni.model.db.Member;

public interface MemberService {
//	/**
//	 * Returns a list of all the members registered in the application.
//	 * 
//	 * @return A list of all the members
//	 */
//	public List<Member> getAllMembers();

	/**
	 * 
	 * @param page
	 *            page number, from 1 to the number of pages
	 * @return
	 */
	public SearchResult<Member> getMembersOfPage(int page, int perPage);

	/**
	 * Adds a new member in the application or update it if it already exists in
	 * database. Consider to use {@link #memberExists(Member)} to check if it
	 * exists, or {@link #addMember(Member)} to do both in once.
	 * 
	 * @param member
	 *            The new member to add
	 * @return True if successfully added, false otherwise.
	 */
	public boolean addOrUpdateMember(Member member);

	public boolean addOrUpdateMembers(List<Member> members);

	/**
	 * add the member if not already in database. otherwise do nothing.
	 * 
	 * @param member
	 * @return <code>true</code> if successfully added, <code>false</code> if
	 *         already exists or if a problem occurred.
	 */
	public boolean addMember(Member member, boolean indexes);

	public boolean addMember(Member member);

	public boolean updateMember(Member member);

	public Member getMember(String login);

//	public Member getMemberFromStringKey(String id);

	public boolean memberExists(Member member);

	/**
	 * Removes the member with the given id from the application.
	 * 
	 * @param id
	 *            The id of the member to remove.
	 * @return True if successfully removed, false otherwise.
	 */
	public Member removeMember(String id);

	public boolean removeAllMembers(MyActionBeanContext context);

	public SearchResult<Member> searchMembers(String queryString, int page,
			int perPage);

	public Member initDefaultMembers();

	public Member initDefaultMembers(boolean isAdmin);

//	public Role getRole(String id);
//
//	public List<Role> getAllRoles();
//
//	public SearchResult<Role> getRolesOfPage(int page, int perPage);
//	
//	public void clearRoles();
//
//	public Role getRoleAdmin();
//
//	public Role getRoleMember();
	
	public static final String ADMIN_LOGIN = "admin";
	public static final String TEST_LOGIN = "test";
	
	Member newMemberAdmin();

//	/**
//	 * Don't check if the role already exists in database. Use
//	 * {@link #roleExists(Role)} to check if it exists, or
//	 * {@link #addRole(Role)} to do both in once.
//	 * 
//	 * @param role
//	 * @return
//	 */
//	public boolean addOrUpdateRole(Role role);
//
//	/**
//	 * Check if the role exists, and if not, add it in database. If found in
//	 * database, do nothing and return false.
//	 * 
//	 * @param role
//	 *            The role to add in database if it does not already exists.
//	 * @return true if successfully added, false if it already exists in
//	 *         database or if a problem occurred when trying to add the role in
//	 *         database.
//	 */
//	public boolean addRole(Role role);
//
//	public boolean roleExists(Role role);
//
//	public boolean roleExists(Member member);
//
//	public Role removeRole(String id);
//
//	public boolean resetRoles();
//
//	public boolean removeRoles();
//
//	public boolean addDefaultRoles();

	public boolean addToIndex(List<Member> members);

	public boolean rebuildIndex();

	public List<FileColumn> getAllFileColumns();

	public boolean resetColumns();

	public boolean updateColumns(List<FileColumn> columns);

	public List<Message> generatePassword(String memberId, Locale locale);

	public List<Message> generateAllPasswords(Locale locale);

//	/**
//	 * @see MemberDaoImpl#newTransactionObject()
//	 */
//	public Transaction newTransactionObject();
//
//	public void beginTransaction(Transaction txn);
//
//	public void commitTransaction(Transaction txn);
//
//	public void rollbackTransaction(Transaction txn);
}
